package com.longrise.co.ui.carfiles.adapter;


import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.longrise.co.R;
import com.longrise.co.ui.carfiles.model.RepairRecord;
import com.longrise.co.ui.carfiles.model.RxRepairRecordBean;
import com.longrise.co.utils.Constants;
import com.ly.common.baserx.RxBus;

import java.util.List;


/**
 * Created by admin on 2017/2/4.
 */

public class RepairRecordAdapter extends BaseQuickAdapter<RepairRecord.ListBean> {


    public RepairRecordAdapter(List<RepairRecord.ListBean> listData) {
        super(R.layout.item_repair_record, listData);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, final RepairRecord.ListBean data) {

        baseViewHolder.setText(R.id.irr_date, data.getRepairdate())
                .setText(R.id.irr_title, data.getCompany())
                .setText(R.id.irr_normal_maintain_value, data.getRepairtype())
                .setText(R.id.irr_mileage_value, data.getRepairdate())
                .setVisible(R.id.repair_complaint, "1".equals(data.getComplaintflag()) ? true : false)
                .setVisible(R.id.repair_evaluation, "0".equals(data.getEvaluateflag()) ? true : false)
                .setOnClickListener(R.id.repair_complaint, new View.OnClickListener() {
                     @Override
                     public void onClick(View v) {
                         RxBus.getInstance().post(Constants.RX_EVENT_REPAIR_RECORD, new RxRepairRecordBean("1", data.getCompanyid(), data.getRecordid(), data.getYears()));
                     }
                 })
                .setOnClickListener(R.id.repair_evaluation, new View.OnClickListener(){
                     @Override
                     public void onClick(View v) {
                         RxBus.getInstance().post(Constants.RX_EVENT_REPAIR_RECORD, new RxRepairRecordBean("2", data.getCompanyid(), data.getRecordid(), data.getYears()));
                     }
                 })
                .setOnClickListener(R.id.repair_detail, new View.OnClickListener(){
                     @Override
                     public void onClick(View v) {
                         RxRepairRecordBean rrd = new RxRepairRecordBean("3", data.getCompanyid(), data.getRecordid(), data.getYears(), data.getCarno());
                         rrd.isEvaluation = "0".equals(data.getEvaluateflag()) ? false : true;
                         rrd.isComplaint = "1".equals(data.getComplaintflag()) ? false : true;
                         RxBus.getInstance().post(Constants.RX_EVENT_REPAIR_RECORD, rrd);
                     }
                 });
    }


}
